<template>
  <div class="user-info-container">
    <el-card class="print-box">
      <el-button type="primary" :loading="printLoading" v-print="printObj">打印</el-button>
    </el-card>
    <el-card>
      <div class="user-info-box" id="userInfoBox">
        <!--    标题    -->
        <h2 class="title">用户信息</h2>
        <!--    头部    -->
        <div class="header">
          <!--    头部表格      -->
          <div class="header-table">
            <el-descriptions :column="2" border>
              <el-descriptions-item label="姓名">{{detailData.username}}</el-descriptions-item>
              <el-descriptions-item label="电话">{{detailData.telephone}}</el-descriptions-item>
              <el-descriptions-item label="邮箱">{{detailData.password}}</el-descriptions-item>
              <el-descriptions-item label="姓名">{{detailData.createAt}}</el-descriptions-item>
              <el-descriptions-item label="角色" span="2">
                <el-tag class="remark" size="default">超级管理员</el-tag>
                <el-tag class="remark" size="default">系统管理员</el-tag>
              </el-descriptions-item>
              <el-descriptions-item label="描述">这个人很懒什么也没有留下</el-descriptions-item>
            </el-descriptions>
          </div>
          <!--    头像      -->
          <el-image class="header-avatar" :src="detailData.avatar"/>
        </div>
        <!--    内容    -->
        <div class="body">
          <el-descriptions direction="vertical" :column="1" border>
            <el-descriptions-item label="经历">
              <ul>
                <li>
                  <span>
                    {{detailData.createAt}}---{{detailData.createAt}}
                  </span>
                  <span>这就是我</span>
                  <span>这个人很懒,什么也没有留下</span>
                </li>
                <li>
                  <span>
                    {{detailData.createAt}}---{{detailData.createAt}}
                  </span>
                  <span>这就是我</span>
                  <span>这个人很懒,什么也没有留下</span>
                </li>
                <li>
                  <span>
                   {{detailData.createAt}}---{{detailData.createAt}}
                  </span>
                  <span>这就是我</span>
                  <span>这个人很懒,什么也没有留下</span>
                </li>
              </ul>
            </el-descriptions-item>
            <el-descriptions-item label="专业">
              搬砖
            </el-descriptions-item>
            <el-descriptions-item label="荣耀">
              荣耀
            </el-descriptions-item>
          </el-descriptions>
        </div>
        <!--    尾部    -->
        <div class="foot">确认______</div>
      </div>
    </el-card>
  </div>
</template>

<script setup lang="ts">
import { ref } from 'vue'
import { getUserDetail } from '../../../api/user'
import { watchSwitchLang } from '../../../utils/i18n'
const props = defineProps({
  id: {
    type: String,
    required: true
  }
})
const detailData = ref({})
const userDetail = async () => {
  detailData.value = await getUserDetail(props.id)
}
// 打印相关
const printLoading = ref(false)
const printObj = {
  // 表示要打印的区域
  id: 'userInfoBox',
  popTitle: 'eatme-web-admin',
  // 打印前
  beforeOpenCallback () {
    printLoading.value = true
  },
  // 执行打印
  OpenCallback () {
    printLoading.value = false
  }

}
userDetail()
watchSwitchLang(getUserDetail)
</script>
<style lang="scss" scoped>
.print-box {
  margin-bottom: 20px;
  text-align: right;
}
.user-info-box {
  width: 1024px;
  margin: 0 auto;
  .title {
    text-align: center;
    margin-bottom: 18px;
  }
  .header {
    display: flex;
    :deep(el-descriptions) {
      flex-grow: 1;
    }
    .header-table {
      width: 100%;
    }
    .header-avatar {
      height: 161px;
      box-sizing: border-box;
      padding: 30px 20px;
      border: 1px solid #ebeef5;
      border-left: none;
    }
    .remark {
      margin-right: 12px;
    }
  }
  .body {
    ul {
      list-style: none;
      li {
        span {
          margin-right: 62px;
        }
      }
    }
  }
  .foot {
    margin-top: 42px;
    text-align: right;
  }
}
</style>
